package com.it.water.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.it.water.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 用户信息 Mapper 接口
 *
 * @author <a href="mailto:2038322151@qq.com">Miraitowa_zcx</a>
 * @author HelloWorld505
 * @version 1.0
 * @since 2024-03-17
 */
@Mapper
public interface UserMapper extends BaseMapper<User> {

    // 根据手机号查询用户信息
    @Select("select id, username, phone, password from users where phone = #{phone}")
    User getByPhone(@Param("phone") String phone);

    // 根据用户名查询用户信息
    @Select("select * from users where username = #{username}")
    User getByUsername(@Param("username") String username);

    // 新增用户
    @Insert("insert into users (username, phone, password) values (#{username}, #{phone}, #{password})")
    void save(User user);
}
